package cn.tedu.shoot;
import java.awt.image.BufferedImage;
public class Hero extends FlyingObject {
	private int life;
	private int doubleFire;
	private int angerslot;
	
	public Hero(){
		super(146,108,183,450);
		life = 3;
		doubleFire = 0;
		angerslot = 0;
	}
	public void step() {
		
	}
	
	/** 英雄机随鼠标移动 */
	void moveTo(int x,int y){//英雄机鼠标移动；
		
		this.x=x-this.width/2;
		this.y=y-this.height/2;
	}
	
	int index=0;;
	public BufferedImage getImage() {
		if(isLife()) {
			return Images.heros[index++%Images.heros.length];
		}
		return null;
	}
	
   public Bullet[] shoot(){
	   int xstep = this.width/4;
	   int ystep = this.y-46;
	   if(doubleFire>100) {
		  Bullet[] bs = new Bullet[3];
			bs[0] = new Bulletx(this.x+0*xstep,ystep);
			bs[1] = new Bullet(this.x+2*xstep-8,ystep);
			bs[2] = new Bulletx(this.x+3*xstep-20,ystep);
			doubleFire-=3;
			return bs;
	   }else if(doubleFire>50) {
			Bullet[] bs = new Bullet[2];
			bs[0] = new Bullet(this.x+0*xstep+20,ystep);
			bs[1] = new Bullet(this.x+3*xstep,ystep);
			doubleFire-=2;
			return bs;
		}else{
			Bullet[] bs = new Bullet[1];
			bs[0] = new Bullet(this.x+2*xstep-8,ystep);
			return bs;
		}
	}



//	public void addLife() {
//		life++;
//	}
  public void addAngerSlot() {
	  if(angerslot<3) {
		  angerslot++;
	  }
    }
  	public int getAngerSlot() {
  		return angerslot;
  	}
  public void clearAngerSlot(){
	  angerslot = 0;
  }
	public void addDoubleFire() {
		doubleFire+=50;
	}
	public void substractLife() {
		life--;
	}
	public void clearDoubleFire() {
		doubleFire=0;
	}
	public int getLife() {
		return life;
	}
	public int getDoubleFire() {
		return doubleFire;
	}
	public void reduceDoubleFire() {
		this.doubleFire-=5;
	}

}
